using System.Configuration;

namespace BSDS.Core.Infrastructure.Configuration
{
    public class ConfigurationLoader
    {
        public BsdsConfiguration Load()
        {
            var configSection = ConfigurationManager.GetSection("bsds") as BsdsConfigurationSection;

            if (configSection == null)
            {
                throw new ConfigurationErrorsException("No configuration found");
            }

            return new BsdsConfiguration(configSection.KeyFilename, configSection.TempFolder, configSection.DeleteTempFilesOnExit, 
                configSection.RequireExclusiveFolderAccess);
        }
    }
}